/**
 *    Copyright 2012 Geensoft S.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/
package ar.com.greensoft.neosystem.model.references;

/**
 * Tipos de Documentos utilizados en el sitema SIDEBA.
 * <p>Se toma como base la Resolución 1361/02 de AFIP
 * en su  <a href="http://www.afip.gov.ar/afip/resol136102_Anexo_II.html">Anexo II</a>.
 * </p>
 * <p>
 * <table>
 * 	<thead><tr><td><strong>C&oacute;digo</strong></td><td><strong>Descripci&oacute;n</strong></td></tr></thead>
 * 	<tbody>
 *    <tr><td>00</td><td>CI Policía Federal</td></tr>
 *    <tr><td>01</td><td>CI Buenos Aires</td></tr>
 *    <tr><td>02</td><td>CI Catamarca</td></tr>
 *    <tr><td>03</td><td>CI Córdoba</td></tr>
 *    <tr><td>04</td><td>CI Corrientes</td></tr>
 *    <tr><td>05</td><td>CI Entre Ríos</td></tr>
 *    <tr><td>06</td><td>CI Jujuy</td></tr>
 *    <tr><td>07</td><td>CI Mendoza</td></tr>
 *    <tr><td>08</td><td>CI La Rioja</td></tr>
 *    <tr><td>09</td><td>CI Salta</td></tr>
 *    <tr><td>10</td><td>CI San Juan</td></tr>
 *    <tr><td>11</td><td>CI San Luis</td></tr>
 *    <tr><td>12</td><td>CI Santa Fe</td></tr>
 *    <tr><td>13</td><td>CI Santiago del Estero</td></tr>
 *    <tr><td>14</td><td>CI Tucumán</td></tr>
 *    <tr><td>16</td><td>CI Chaco</td></tr>
 *    <tr><td>17</td><td>CI Chubut</td></tr>
 *    <tr><td>18</td><td>CI Formosa</td></tr>
 *    <tr><td>19</td><td>CI Misiones</td></tr>
 *    <tr><td>20</td><td>CI Neuquén</td></tr>
 *    <tr><td>21</td><td>CI La Pampa</td></tr>
 *    <tr><td>22</td><td>CI Río Negro</td></tr>
 *    <tr><td>23</td><td>CI Santa Cruz</td></tr>
 *    <tr><td>24</td><td>CI Tierra del Fuego</td></tr>
 *    <tr><td>80</td><td>CUIT</td></tr>
 *    <tr><td>86</td><td>CUIL</td></tr>
 *    <tr><td>87</td><td>CDI</td></tr>
 *    <tr><td>89</td><td>LE</td></tr>
 *    <tr><td>90</td><td>LC</td></tr>
 *    <tr><td>91</td><td>CI extranjera</td></tr>
 *    <tr><td>92</td><td>en trámite</td></tr>
 *    <tr><td>93</td><td>Acta nacimiento</td></tr>
 *    <tr><td>95</td><td>CI Bs. As. RNP</td></tr>
 *    <tr><td>96</td><td>DNI</td></tr>
 *    <tr><td>94</td><td>Pasaporte</td></tr>
 *    <tr><td>99</td><td>Sin identificar/venta global diaria</td></tr> 
 *  </tbody>
 * </table>
 * </p>
 * <p>
 * <ul>
 * 	<li><strong>DNI</strong>: Documento Nacional de Identidad.</li>
 * 	<li><strong>LC</strong>: Libreta Cívica.</li>
 * 	<li><strong>LE</strong>: Libreta de Enrolamiento.</li>
 * 	<li><strong>PASAPORTE</strong>: Pasaporte usa por los extranjeros.</li>
 * 	<li><strong>CUIT</strong>: Código Único de Identificación Tributaria.</li>
 * 	<li><strong>CUIL</strong>: Código Único de Identificación Laboral.</li>
 * </ul>
 * </p>
 * @author Jorge E. Villaverde
 * @since 1.0.0
 * @version 1.0.0
 */
public enum TipoDocumento implements LabeledEnum{
	CUIL(81, "td_cuil"),
	CUIT(80, "td_cuit"),
	CDI(87, "td_cdi"),
	PASAPORTE(94, "td_pasaporte"),
	LE(89, "td_le"),
	LC(90, "td_lc"),
	DNI(96, "td_dni");
	
	private int value;
	private final String label;
	 
	private TipoDocumento(int value, String label){
		this.value = value;
		this.label = label;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}
	 
    public static TipoDocumento parse(int id) {
    	TipoDocumento td = null; // Default
    	
    	/*
    	 * Cédulas de Indetidad
    	 **/
    	if(id >= 0 && id <= 24 || id == 95)
    		return CDI;
    	
        for (TipoDocumento item : TipoDocumento.values()) {
            if (item.getValue()==id) {
                td = item;
                break;
            }
        }
        return td;
    }

	@Override
	public String getLabel() {
		return label;
	}
}